using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.SqlServer.Management.Smo;

namespace Index_Management
{
    public partial class Form1 : Form
    {
        Server DataSource;
        Database DB;

        public Form1()
        {
            InitializeComponent();
        }

        //private void comboBox1_GotFocus(object sender, EventArgs e)
        //{
        //    try
        //    {
        //        DataSource = new Server(textBox_DataSource.Text);
        //        foreach (Database DB in DataSource.Databases)
        //        {
        //            comboBox_Catalog.Items.Add(DB.Name);
        //        }
        //    }
        //    catch (Exception E)
        //    {
        //        MessageBox.Show("Could not connect to the Data Source " + textBox_DataSource.Text);
        //    }
        //}

        //private void button_Connect_Click(object sender, EventArgs e)
        //{
        //    Form2 ConnectToDS = new Form2();
        //    ConnectToDS.ShowDialog();
        //    DataSource = ConnectToDS.getDataSource();
        //    DB = ConnectToDS.getDB();
        //    MessageBox.Show("Returned : " + DataSource.Name + "  " + DB.Name);
        //    //clearListBox();
        //    //try
        //    //{
        //    //    DB = DataSource.Databases[comboBox_Catalog.SelectedIndex];
        //    //    MessageBox.Show("Connection Succeeded to database " + DB.Name);
        //    //    loadTableList();
        //    //}
        //    //catch (Exception E)
        //    //{
        //    //    MessageBox.Show("Unable to connect to database " + comboBox_Catalog.SelectedItem.ToString());
        //    //}
        //}

        //private void loadTableList()
        //{
        //    for (int TableCount = 0; TableCount < DB.Tables.Count; TableCount++)
        //    {
        //        checkedListBox_Tables.Items.Add(DB.Tables[TableCount].Schema + "." + DB.Tables[TableCount].Name);
        //    }
        //}
        //private void clearListBox()
        //{
        //    //checkedListBox_Tables.Items.Clear();
        //}

        //private void button_LoadTableList_Click(object sender, EventArgs e)
        //{
        //    clearListBox();
        //    try
        //    {
        //        foreach (Table tab in DB.Tables)
        //        {
        //            //checkedListBox_Tables.Items.Add(tab.Schema + "." + tab.Name);
        //        }
        //    }
        //    catch (Exception E)
        //    {
        //        MessageBox.Show("Could not obtain table list");
        //    }
        //}

        private void button_Cancel_Click(object sender, EventArgs e)
        {
            DialogResult CancelWizard = MessageBox.Show("Are you sure you want to exit the wizard?", "Cancel wizard.", MessageBoxButtons.YesNo);
            if (CancelWizard == DialogResult.Yes)
            {
                Application.Exit();
            }
        }

        private void button_Next_Click(object sender, EventArgs e)
        {
            this.Hide();
            Form3 scriptConstraints = new Form3();
            scriptConstraints.ShowDialog();
            this.Close();
            this.Dispose();
        }

    }
}